﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace WcfContrib.Utils
{
    static class ConsoleHelper
    {
        #region Console Window
        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern IntPtr GetConsoleWindow();

        static bool? hasConsole;
        internal static bool HasConsoleWindow()
        {
            if (!hasConsole.HasValue)
            {
                hasConsole = GetConsoleWindow() != IntPtr.Zero;
            }

            return hasConsole.Value;
        }
        #endregion
    }
}
